package com.wogu.jwa.web.admin;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;

import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;

import com.wogu.jwa.web.admin.classes.Member;

public class Welcome extends Member {
	
	public void defaultGet() throws IOException, ServletException {
		RequestDispatcher view = request.getRequestDispatcher("/WEB-INF/template/welcome.jsp");
		view.forward(request, response);
	}
	
	public void getLocationGet() throws IOException, ServletException {
		String ip = request.getParameter("ip");
		URL url = new URL("http://whois.pconline.com.cn/ip.jsp?ip=" + ip);
		InputStreamReader in = null;
		try {
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();
			conn.setDoInput(true);
			conn.connect();
			in = new InputStreamReader(conn.getInputStream());
			int chr;
			while(-1 != (chr = in.read())) {
				out.print((char) chr);
			}
		} finally {
			if(null != in) {
				in.close();
			}
		}
	}
}